import org.bouncycastle.pqc.math.linearalgebra.ByteUtils;

import java.util.Arrays;

public class sm3_demo extends GMBaseTest {
    public static void main(String[] args) {
        testHashAndVerify();
        testHmacSM3();
    }

    public static void testHashAndVerify() {

        byte[] hash = SM3Util.hash(SRC_DATA);
        System.out.println("SM3 HASH result:\n" + ByteUtils.toHexString(hash));
        boolean flag = SM3Util.verify(SRC_DATA, hash);
        if (!flag) {
            System.out.println("验证不成功\n");
        }
    }

    public static void testHmacSM3() {
        byte[] hmacKey = new byte[]{1, 2, 3, 4, 5, 6, 7, 8};
        byte[] hmac = SM3Util.hmac(hmacKey, SRC_DATA);
        System.out.println("SM3 HMAC result:\n" + Arrays.toString(hmac));
    }

}